﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ERPU8WebApi.Models
{
    /// <summary>
    /// 返回的Model
    /// </summary>
    public class ResponseModel
    {
        /// <summary>
        /// 响应代码   0:失败  1：成功
        /// </summary>
        public int ResultCode { get; set; }
        /// <summary>
        /// 错误信息
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// 返回结果
        /// </summary>
        public object Data { get; set; }
    }

    public enum ResponseCode
    {
        OK = 1,                 //执行成功
        PARAMETERERROR,         //参数错误
        APIERROR,               //U8API异常
        USERERROR,              //用户名不存在
        //BlanceLow = 101,        //余额不足
        //UserNotExist = 0,     //户号不存在
        //UserIsEmpty = 103,      //户号为空
        //MeterNoExist = -1,     //表地址不存在
        //MeterIsEmpty = 105,     //表地址为空
        //UserMeterIsEmpty = -2,      //户号表号为空
        //TransactionIdNoExist = 106,//流水号不存在
        //TransactionIdIsEmpty = -3,//流水号为空
        //MoneyLimit = -4,            //充值金额必须大于0
        //PayDateIsEmpty = -5,        //充值日期不能为空
        //PayWayError = -6,         //支付方式不正确
        //MeterMark = -7,          //表具状态为已销表
        //PriceNoExist = 108,     //价格信息不存在
        //PriceIsEmpty = 109,     //价格编号为空
        //FormatError = -200,      //格式不正确，无法正确解析
        //TsError = -201,          //时间戳重复或错误
        //AccessTokenError = -202, //鉴权信息验证错误
        //OperDatabaseErr = -203,//数据库操作错误
        OtherError = -999        //未知异常
    }

    public class ResponseMsg
    {
        /// <summary>
        /// 获取异常信息
        /// </summary>
        /// <param name="resCode"></param>
        /// <returns></returns>
        public static string Msg(ResponseCode resCode)
        {
            switch (resCode)
            {
                case ResponseCode.OK: return "Request Successful";
                case ResponseCode.PARAMETERERROR: return "参数错误";
                case ResponseCode.APIERROR: return "U8API异常";
                //case ResponseCode.Error: return "Error";
                //case ResponseCode.UserMeterIsEmpty: return "The user No. and the meter No. cannot both be null";
                //case ResponseCode.ReqNotExists: return "The requested resource does not exist";
                //case ResponseCode.BlanceLow: return "Lack of balance";
                //case ResponseCode.FormatError: return "Data format error, unable to parse correctly";
                //case ResponseCode.TsError: return "Duplicate or wrong timestamp";
                //case ResponseCode.AccessTokenError: return "Authentication information validation error";
                //case ResponseCode.UserNotExist: return "User No. does not exist";
                //case ResponseCode.UserIsEmpty: return " The user number is empty ";
                //case ResponseCode.MeterNoExist: return "Meter No. does not exist";
                //case ResponseCode.MeterIsEmpty: return " The meterAddr is empty ";
                //case ResponseCode.TransactionIdNoExist: return "TransactionId does not exist ";
                //case ResponseCode.TransactionIdIsEmpty: return "Recharge serial number cannot be null";
                //case ResponseCode.PriceNoExist: return "No price was found ";
                //case ResponseCode.PriceIsEmpty: return "The price number is empty ";
                //case ResponseCode.OperDatabaseErr: return "Database operation error";
                //case ResponseCode.MoneyLimit: return "The recharge amount must be larger than 0";
                //case ResponseCode.PayDateIsEmpty: return "The recharge date cannot be null";
                //case ResponseCode.MeterMark: return "The meter ID has been canceled";
                //case ResponseCode.PayWayError: return "The payment type is incorrect";
                default: return "Unknown anomaly";
            }
        }
    }

    public class ResponseObj
    {
        public string Result;
        public string ErrMsg;
        public string VouchId;
        public string CCode;
    }
}